import React from 'react'

import {useDispatch,useSelector} from "react-redux"
import {getMovieAction} from "../../store/slice/movieSlice"

export default function Movie() {
  // 推送值上去共享状态
  const count=useSelector(state=>state.count.count)
  const movieList=useSelector(state=>state.movie.movieList)
  const dispatch=useDispatch();
  
  
  const movieHandle=()=>{
    // 这里的dispatch只是让中间件执行了异步的axios
    dispatch(getMovieAction())

    console.log(movieList)

  }

  return (
    <div>
      <h1>我是Movie组件</h1>
      <p>我收到的Count组件的值是 {count}</p>

      <ul>
      {
          movieList.map(item=>{
            // react里面render不能直接是对象  
            return <li key={item.tvId}>{item.albumName}</li>;
          })
        }
      </ul>
      <button onClick={movieHandle}>电影数据</button>
    </div>
  )
}
